﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace RecipeRecommender
{
    class CCaseLoader
    {

        public CCaseLoader()
        {
            cIngredientStrings = new Hashtable();
            cRecipeList = new List<Recipe>();
            //CIngredient[] cIng = { Ingredient.PORK, Ingredient.SPINACH };
            //AddRecipe (Cuisine.WESTERN, cIng , MealType.MAIN, "Spinach Pork");

            //CIngredient[] cIng2 = { Ingredient.RED_BEAN };
            //AddRecipe(Cuisine.CHINESE, cIng2, MealType.DESSERT, "RED Bean Soup");

            //CIngredient[] cIng3 = { Ingredient.CHICKEN, Ingredient.CABBAGE };
            //AddRecipe(Cuisine.CHINESE, cIng3, MealType.SIDE, "Chicken Cabbage");
           
            //CIngredient[] cIng4 = {new CCabbage(), new CSpinach()};
            //AddRecipe (Cuisine.CHINESE, cIng4, MealType.SIDE, "Spinach Cabbage soup");

            //CIngredient[] cIng5 = { new CMeat(), new CSpinach() };
            //AddRecipe(Cuisine.WESTERN, cIng5, MealType.SIDE, "Spinach Meat dish");

           // CIngredient[] cIng6 = { new CChicken(), new CCabbage() };
            //AddRecipe(Cuisine.WESTERN, cIng6, MealType.SIDE, "Chicken Cabbage Casserole");

            //CIngredient[] cIng7 = { new CBeef()};
            //AddRecipe(Cuisine.WESTERN, cIng7, MealType.SIDE, "Beef Stew");

            //CIngredient[] cIng8 = { new CPork(), new CSpinach() };
            //AddRecipe(Cuisine.WESTERN, cIng8, MealType.SIDE, "Fried Spinach Pork");


        }

        public void loadStrings()
        {
           // cIngredientStrings.Add(Ingredient.PORK, "Pork");
          //  cIngredientStrings.Add(Ingredient.VEGETABLE, "Vegetable");
          //  cIngredientStrings.Add(Ingredient.BROCOLLI, "Brocolli");
            
        }

        public List<Recipe> getRelevantCases(Recipe cQuery)
        {
            List<Recipe> cSelectedRecipes = new List<Recipe>();

            foreach (Recipe cRec in cRecipeList)
            {
                double dSim = getSimilarity(cRec, cQuery);
                cRec.Similarity = dSim;

                cSelectedRecipes.Add(cRec);
            }
            return cSelectedRecipes;
        }

        public double getSimilarity(Recipe cCompare, Recipe cQuery)
        {

            /*
            List<CIngredient> cQueryIngredients;
            List<CIngredient> cCompareIngredients;

            cCompareIngredients = cCompare.Ingredients;

            cQueryIngredients = cQuery.Ingredients;


            double dSimilarity = 0;

            foreach (CIngredient cQueryIng in cQueryIngredients)
            {
                foreach (CIngredient cCompareIng in cCompareIngredients)
                {
                    if (cCompareIng.GetType() == cQueryIng.GetType())
                    {
                        dSimilarity += 5;
                    }
                    if (cCompareIng.GetType().BaseType == cQueryIng.GetType().BaseType)
                    {
                        dSimilarity += 3;
                    }
                }
            }
             
            return dSimilarity;
             */
            return 0;
        }

        void AddRecipe(Cuisine cCuisine, CIngredient[] cIng, MealType cType, String strName)
        {

            /*
            Recipe r1 = new Recipe();
            r1.Cuisine = cCuisine;
            List<CIngredient> cIngredients = new List<CIngredient>();
            for (int i = 0; i < cIng.Length; i++)
            {
                cIngredients.Add(cIng[i]);
            }
            
            r1.Ingredients = cIngredients;
            r1.MealType = cType;
            r1.Name = strName;
            cRecipeList.Add(r1);
             */
        }

        private List<Recipe> cRecipeList;
        private Hashtable cIngredientStrings;
    }
}
